<script type="text/javascript">
	function newCookie(name, value, days) {
		var days = 365;
		if (days) {
			var date = new Date();
			date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
			var expires = "; expires=" + date.toGMTString();
		} else
			var expires = "";
		document.cookie = name + "=" + value + expires + "; path=/";
	}

	function readCookie(name) {
		var nameSG = name + "=";
		var nuller = '';
		if (document.cookie.indexOf(nameSG) == -1)
			return nuller;

		var ca = document.cookie.split(';');
		for ( var i = 0; i < ca.length; i++) {
			var c = ca[i];
			while (c.charAt(0) == ' ')
				c = c.substring(1, c.length);
			if (c.indexOf(nameSG) == 0)
				return c.substring(nameSG.length, c.length);
		}
		return null;
	}

	function eraseCookie(name) {
		newCookie(name, "", 1);
	}

	function createRememberMe() {
		newCookie('loginname', document.frmLogin.loginname.value);
		newCookie('password', document.frmLogin.password.value);
	}

	function deleteRememberMe() {
		eraseCookie('loginname');
		eraseCookie('password');
		document.frmLogin.loginname.value = '';
		document.frmLogin.password.value = '';
	}

	function remCookie() {		
		var loginname = readCookie("loginname");
		if (loginname) {			
			document.frmLogin.loginname.value = loginname;
			document.frmLogin.password.value = readCookie("password");
			jQuery('input[name="keepSignIn"]').attr("checked", true);
		} else {
			jQuery('input[name="keepSignIn"]').attr("checked", false);
		}
	}

	function addLoadEvent(func) {
		var oldonload = window.onload;
		if (typeof window.onload != 'function') {
			window.onload = func;
		} else {
			window.onload = function() {
				if (oldonload) {
					oldonload();
				}
				func();
			}
		}
	}

	jQuery(document).ready(function() {
		jQuery('input[name="keepSignIn"]').click(function() {
			if (jQuery('input[name="keepSignIn"]').attr("checked") == true) {
				createRememberMe();
			} else {
				deleteRememberMe();
			}
		});

		addLoadEvent(function() {
			remCookie();
		});
	});
</script>